﻿<UserControl    x:Class="UControls.ucCalculator"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:draw="clr-namespace:System.Windows.Media;assembly=System.Windows"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" Padding="0,0,3,0">

    <UserControl.Resources>
        <draw:SolidColorBrush x:Key="theameBG">#046380</draw:SolidColorBrush>
        <Style TargetType="Button" x:Name="resourceCenterButton">
            <Setter Property="Foreground" Value="WhiteSmoke"></Setter>
            <Setter Property="FontSize" Value="10"></Setter>
            <Setter Property="Margin" Value="10 0 0 0"></Setter>
            <Setter Property="Height" Value="21"></Setter>
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="#ADA26B" />
            <Setter Property="Padding" Value="8,3" />
            <Setter Property="FontWeight" Value="SemiBold" />
            <Setter Property="MinWidth" Value="60" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="White" Offset="0"/>
                        <GradientStop Color="#FFA8E232" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#A3CA8D"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#A3CA8D"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#A3CA8D"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="#A3CA8D"/>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#2C8541"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#2C8541"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#2C8541"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#2C8541"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Unfocused" />
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background" CornerRadius="5" 
                                    Background="#4D9A39" 
                                    BorderThickness="{TemplateBinding BorderThickness}" 
                                    BorderBrush="{TemplateBinding BorderBrush}">
                                <Grid Background="{TemplateBinding Background}"  
                                      Margin="1">
                                    <Border Opacity="0"  x:Name="BackgroundAnimation" Background="#FF448DCA" />
                                    <Rectangle x:Name="BackgroundGradient" >
                                        <Rectangle.Fill>
                                            <LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
                                                <GradientStop Color="#A3CA8D" Offset="0" />
                                                <GradientStop Color="#64A949" Offset="0.375" />
                                                <GradientStop Color="#4D9A39" Offset="0.625" />
                                                <GradientStop Color="#2C8541" Offset="1" />
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Grid>
                            </Border>
                            <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>
                            <Rectangle x:Name="DisabledVisualElement" RadiusX="5" RadiusY="5" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" />
                            <Rectangle x:Name="FocusVisualElement" RadiusX="5" RadiusY="5" Margin="1" Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="Button" x:Name="resCenterButtonSmall" BasedOn="{StaticResource resourceCenterButton}">
            <Setter Property="FontSize" Value="11"></Setter>
            <Setter Property="Height" Value="25"></Setter>
            <Setter Property="MinWidth" Value="10" />
            <Setter Property="Margin" Value="2 2 3 0"/>
            <Setter Property="Padding" Value="0" />
        </Style>

        <Style TargetType="Button" x:Name="resOprCenterButton">
                <Setter Property="Foreground" Value="WhiteSmoke"></Setter>
                <Setter Property="FontSize" Value="11"></Setter>
                <Setter Property="Margin" Value="2 2 3 0"></Setter>
            <Setter Property="Height" Value="25"></Setter>
                <Setter Property="BorderThickness" Value="2" />
                <Setter Property="BorderBrush" Value="#00000000" />
                <Setter Property="Padding" Value="0" />
                <Setter Property="FontWeight" Value="SemiBold" />
                <Setter Property="MinWidth" Value="10" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="White" Offset="0"/>
                            <GradientStop Color="#FFA8E232" Offset="1"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid>
                                <vsm:VisualStateManager.VisualStateGroups>
                                    <vsm:VisualStateGroup x:Name="CommonStates">
                                        <vsm:VisualState x:Name="Normal"/>
                                        <vsm:VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#FFEDAEAE"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#FFEDAEAE"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#FFEDAEAE"/>
                                            </Storyboard>
                                        </vsm:VisualState>
                                        <vsm:VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="#A3CA8D"/>
                                                <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#2C8541"/>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#2C8541"/>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#2C8541"/>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#2C8541"/>
                                            </Storyboard>
                                        </vsm:VisualState>
                                        <vsm:VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55"/>
                                            </Storyboard>
                                        </vsm:VisualState>
                                    </vsm:VisualStateGroup>
                                    <vsm:VisualStateGroup x:Name="FocusStates">
                                        <vsm:VisualState x:Name="Focused">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>
                                            </Storyboard>
                                        </vsm:VisualState>
                                        <vsm:VisualState x:Name="Unfocused" />
                                    </vsm:VisualStateGroup>
                                </vsm:VisualStateManager.VisualStateGroups>
                                <Border x:Name="Background" CornerRadius="5" 
                                    Background="#FFD83636" 
                                    BorderThickness="{TemplateBinding BorderThickness}" 
                                    BorderBrush="{TemplateBinding BorderBrush}">
                                    <Grid Background="{TemplateBinding Background}"  
                                      Margin="1">
                                        <Border Opacity="0"  x:Name="BackgroundAnimation" Background="#00000000" />
                                        <Rectangle x:Name="BackgroundGradient" >
                                            <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFE7BBBB" Offset="0"/>
                                                <GradientStop Color="#FFDC3D3D" Offset="1"/>
                                                <GradientStop Color="#FFD83F3F" Offset="0.435"/>
                                                <GradientStop Color="#FFD83636" Offset="0.685"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                        </Rectangle>
                                    </Grid>
                                </Border>
                                <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>
                                <Rectangle x:Name="DisabledVisualElement" RadiusX="5" RadiusY="5" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" />
                                <Rectangle x:Name="FocusVisualElement" RadiusX="5" RadiusY="5" Margin="1" Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
           

        </Style>

        <Style TargetType="Button" x:Name="resNumericCenterButton">
            <Setter Property="Foreground" Value="WhiteSmoke"></Setter>
            <Setter Property="FontSize" Value="11"></Setter>
            <Setter Property="Margin" Value="2 2 3 0"></Setter>
            <Setter Property="Height" Value="25"></Setter>
            <Setter Property="BorderThickness" Value="2" />
            <Setter Property="BorderBrush" Value="#00000000" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="FontWeight" Value="SemiBold" />
            <Setter Property="MinWidth" Value="10" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="White" Offset="0"/>
                        <GradientStop Color="#FFA8E232" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>                                           
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#FFA5C1E0"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#FFA5C1E0"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#FFA5C1E0"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="DarkBlue"/>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#FF365ED8"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#FF365ED8"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#FF365ED8"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#FF365ED8"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Unfocused" />
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background" CornerRadius="5" 
                                    Background="#FF9B9FDC" 
                                    BorderThickness="{TemplateBinding BorderThickness}" 
                                    BorderBrush="{TemplateBinding BorderBrush}">
                                <Grid Background="{TemplateBinding Background}"  
                                      Margin="1">
                                    <Border Opacity="0"  x:Name="BackgroundAnimation" Background="#00000000" />
                                    <Rectangle x:Name="BackgroundGradient" >
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFA5C1E0" Offset="0"/>
                                                <GradientStop Color="#FFA0B6EB" Offset="1"/>
                                                <GradientStop Color="#FF5B73D4" Offset="0.435"/>
                                                <GradientStop Color="#FF365ED8" Offset="0.685"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Grid>
                            </Border>
                            <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>
                            <Rectangle x:Name="DisabledVisualElement" RadiusX="5" RadiusY="5" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" />
                            <Rectangle x:Name="FocusVisualElement" RadiusX="5" RadiusY="5" Margin="1" Stroke="#FF38498B" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>


        </Style>

        <Style TargetType="Button" x:Name="resMemoryCenterButton">
            <Setter Property="Foreground" Value="WhiteSmoke"></Setter>
            <Setter Property="FontSize" Value="11"></Setter>
            <Setter Property="Margin" Value="2 2 3 0"></Setter>
            <Setter Property="Height" Value="25"></Setter>
            <Setter Property="BorderThickness" Value="2" />
            <Setter Property="BorderBrush" Value="#00000000" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="FontWeight" Value="SemiBold" />
            <Setter Property="MinWidth" Value="10" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="White" Offset="0"/>
                        <GradientStop Color="#FFA8E232" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#FFBEC2C6"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#FFBEC2C6"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#FFBEC2C6"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="#FF685D5F"/>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#FFA9ACB2"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#FFA9ACB2"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#FFA9ACB2"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#FFA9ACB2"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Unfocused" />
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background" CornerRadius="5" 
                                    Background="#FF8B8D95" 
                                    BorderThickness="{TemplateBinding BorderThickness}" 
                                    BorderBrush="{TemplateBinding BorderBrush}">
                                <Grid Background="{TemplateBinding Background}"  
                                      Margin="1">
                                    <Border Opacity="0"  x:Name="BackgroundAnimation" Background="#00000000" />
                                    <Rectangle x:Name="BackgroundGradient" >
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFBEC2C6" Offset="0"/>
                                                <GradientStop Color="#FFA9ACB2" Offset="1"/>
                                                <GradientStop Color="#FF8B8D95" Offset="0.435"/>
                                                <GradientStop Color="#FF685D5F" Offset="0.685"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Grid>
                            </Border>
                            <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"/>
                            <Rectangle x:Name="DisabledVisualElement" RadiusX="5" RadiusY="5" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" />
                            <Rectangle x:Name="FocusVisualElement" RadiusX="5" RadiusY="5" Margin="1" Stroke="#FF38498B" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Border BorderBrush="Black" 
                BorderThickness="1,1,2,3" 
                HorizontalAlignment="Left" 
                VerticalAlignment="Top" 
                Width="207" 
                Padding="2"
                CornerRadius="5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="2*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition Width="40"/>                    
                </Grid.ColumnDefinitions>
                <Border  
                         BorderThickness="2"
                         BorderBrush="Black"
                         Grid.Column="0" 
                    Margin="1"
					     Grid.ColumnSpan="5"
                         CornerRadius="5">
                    
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="2*"/>                        
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="15*"/>                            
                        </Grid.ColumnDefinitions>
                        <TextBox x:Name="txtMemoryDisplay"
                                 TextWrapping="Wrap" 
                                 Text="{Binding MemDisplay,Mode=TwoWay}"        
                                 FontSize="11"
                                 FontWeight="Bold"
                                 Foreground="{StaticResource theameBG}"
                                 BorderThickness="0"				 
                                 TextAlignment="Center"
                                 VerticalContentAlignment="Center"
                                 d:LayoutOverrides="Height"                                  
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Stretch"
                                 Margin="0,0,0,0" 
                                 Grid.Column="0"
                                 Grid.Row="0"                                 
                                 IsReadOnly="True" 
                                 Padding="0" />

                        <TextBox x:Name="txtFirstOperand"
                                 TextWrapping="Wrap" 
                                 Text="{Binding firstOperand,Mode=TwoWay}"        
                                 FontSize="10"                                                                
                                 BorderThickness="0"				 
                                 TextAlignment="Right"
                                 VerticalContentAlignment="Center"
                                 d:LayoutOverrides="Height"                                  
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Stretch"
                                 Margin="0,0,2,0" 
                                 Grid.Column="1"
                                 Grid.Row="0"                                 
                                 IsReadOnly="True" 
                                 Padding="0" />


                        <TextBox x:Name="txtDisplayNumber"
                                 TextWrapping="Wrap" 
                                 Text="{Binding currentScreen,Mode=TwoWay}"        
                                 BorderThickness="0"				 
                                 TextAlignment="Right"
                                 FontSize="12"
                                 FontWeight="Bold" 
                                 VerticalContentAlignment="Bottom"
                                 d:LayoutOverrides="Height" 
                                 Foreground="#FF5D6A35"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Stretch"
                                 Margin="0,0,2,0" Grid.Row="1"
                                 Grid.ColumnSpan="2"
                                 IsReadOnly="True" 
                                 Cursor="IBeam" Padding="0" />
                    </Grid>
                </Border>
                <!-- Row One -->

                <Button   Style="{StaticResource resMemoryCenterButton}" 				
				 Content="MS" 
				 Width="35"
				 Grid.Row="1" 
				 Grid.Column="0"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                           Click="Operation_MSave_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resMemoryCenterButton}" 				
				 Content="MC" 
				 Width="35"
				 Grid.Row="1" 
				 Grid.Column="2"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_MC_Button_Click">
                    
                </Button>


                <Button   Style="{StaticResource resMemoryCenterButton}" 				
				 Content="M+" 
				 Width="35"
				 Grid.Row="1" 
				 Grid.Column="3"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                           Click="Operation_MPLUS_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resMemoryCenterButton}" 				
				 Content="M-" 
				 Width="35"
				 Grid.Row="1" 
				 Grid.Column="4"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                           Click="Operation_MMINUS_Button_Click"
				 >
                </Button>
                <Button   Style="{StaticResource resMemoryCenterButton}" 				
				 Content="MR" 
				 Width="35"
				 Grid.Row="1" 
				 Grid.Column="1"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                           Click="Operation_MR_Button_Click"
				 >
                </Button>

                <!-- Row Two -->

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="C" 
				 Width="35"
				 Grid.Row="2" 
				 Grid.Column="0"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                           Click="Operation_CLEAN_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="+/-"
				 Width="35"
				 Grid.Row="3" 
				 Grid.Column="4"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                           Click="Operation_PLUSMINUS_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="√" 
				 Width="35"
				 Grid.Row="2" 
				 Grid.Column="1"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                Click="Operation_SQRT_Button_Click"
				 >
                </Button>

                

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="1/x" 
				 Width="35"
				 Grid.Row="3" 
				 Grid.Column="3"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                Click="Operation_ONEUPONX_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resOprCenterButton}" 				
				 Content="/" 
				 Width="35"
				 Grid.Row="4" 
				 Grid.Column="3"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resOprCenterButton}" 				
				 Content="X" 
				 Width="35"
				 Grid.Row="4" 
				 Grid.Column="4"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>
                <!-- Row Three -->

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="7" 
				 Width="35"
				 Grid.Row="3" 
				 Grid.Column="0"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click" Height="23">
                </Button>

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="8"
				 Width="35"
				 Grid.Row="3" 
				 Grid.Column="1"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="9" 
				 Width="35"
				 Grid.Row="3" 
				 Grid.Column="2"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="x^2" 
				 Width="35"
				 Grid.Row="2" 
				 Grid.Column="2"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                Click="Operation_XPOW2_Button_Click"
				 >
                </Button>
                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="x^3" 
				 Width="35"
				 Grid.Row="2" 
				 Grid.Column="3"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                Click="Operation_XPOW3_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="x^y" 
				 Width="35"
				 Grid.Row="2" 
				 Grid.Column="4"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resOprCenterButton}" 				
				 Content="-" 
				 Width="35"
				 Grid.Row="5" 
				 Grid.Column="5"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>
                <!-- Row Four -->

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="4" 
				 Width="35"
				 Grid.Row="4" 
				 Grid.Column="0"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="5"
				 Width="35"
				 Grid.Row="4" 
				 Grid.Column="1"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="6" 
				 Width="35"
				 Grid.Row="4" 
				 Grid.Column="2"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resOprCenterButton}" 				
				 Content="+" 
				 Width="35"
				 Grid.Row="5" 
				 Grid.Column="3"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                 Click="Operation_Button_Click"                          
                          >
                </Button>
                <!-- Row Five -->

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="1" 
				 Width="35"
				 Grid.Row="5" 
				 Grid.Column="0"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="2"
				 Width="35"
				 Grid.Row="5" 
				 Grid.Column="1"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="3" 
				 Width="35"
				 Grid.Row="5" 
				 Grid.Column="2"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>
                <!-- Row Six-->

                <Button   Style="{StaticResource resNumericCenterButton}" 				
				 Content="0"
				 Grid.Row="6" 
				 Grid.Column="0"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 FontWeight="Bold" 
				 Click="Operation_Button_Click"
				 RenderTransformOrigin="1.029,0.455" 
				 HorizontalAlignment="Center" Width="73" Grid.ColumnSpan="2" Margin="1"/>

                <Button   Style="{StaticResource resCenterButtonSmall}" 				
				 Content="."
				 Width="35"
				 Grid.Row="6" 
				 Grid.Column="2"
				 Margin="1"
				 Background="#25517D"
				 VerticalAlignment="Center"
				 HorizontalAlignment="Center"
				 FontWeight="Bold" 
                          Click="Operation_Button_Click"
				 >
                </Button>
                <Button Background="#25517D" Content="=" FontWeight="Bold" 
                        Click="Operation_EQUAL_Button_Click"
                        HorizontalAlignment="Center" Margin="1" 
                        Style="{StaticResource resOprCenterButton}" 
                        VerticalAlignment="Center"
                         Grid.Column="3" Grid.Row="6" 
                        Width="70"
                        Grid.ColumnSpan="2" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

